#include "Score.h"

#include <sstream>
Score::Score(Position* pos)
{
	this->valor=0;
	this->total_balls=0;
	this->total_shoots=0;
	this->points=0;
	this->str_points="0";
	if (pos==NULL)
		position_score=new Position(300,0);
	else 
		position_score=new Position((pos->getPixelX()>>1),0);
	color_font=new Color("205","235","0");
}

Score::~Score(void)
{
}

string Score::getPoints()
{
	return this->str_points;
}
void Score::registerScore(int ballNumber)
{
	if(ballNumber==0){
		this->points=0;
	}else{
		this->points+=CONST_PTS* ballNumber + pow((double)5,(ballNumber-3));
	}
	setScore(this->points);
	
}
void Score::draw()
{
	SketcherHelper::getInstance()->printText(this->position_score,this->color_font,this->getPoints());		
}

double Score::getScore(){
	return this->points;
}

void Score::setScore(double points){
	this->points=points;
	stringstream sstream;	
	sstream << this->points;
	int found=sstream.str().find(".");
	if (found>=0)
		this->str_points=sstream.str().replace(found,1,"");
	else 
		this->str_points=sstream.str();
	this->draw();
}
	

void Score::SetColor(int r, int g, int b)
{
	
	return;
}